﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ICeFramework.Web.Common.Attributes
{
    [global::System.AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
    public sealed class JavaScriptAttribute : Attribute
    {
        #region public string Name
        /// <summary>
        /// Get/Sets the Name of the JavaScriptAttribute
        /// </summary>
        /// <value></value>
        public string Name
        {
            get;
            private set;
        }
        #endregion

        #region public Type Type
        /// <summary>
        /// Get/Sets the Type of the JavaScriptAttribute
        /// </summary>
        /// <value></value>
        public Type Type
        {
            get;
            set;
        }
        #endregion

        #region public object DefaultValue
        /// <summary>
        /// Get/Sets the DefaultValue of the JavaScriptAttribute
        /// </summary>
        /// <value></value>
        public object DefaultValue
        {
            get;
            set;
        }
        #endregion

        #region public bool IsComplex
        /// <summary>
        /// Gets the IsComplex of the JavaScriptAttribute
        /// </summary>
        /// <value></value>
        public bool IsComplex
        {
            get { return !string.IsNullOrEmpty(Name); }
        }
        #endregion

        #region public JavaScriptAttribute(string variableName, Type variableType)
        /// <summary>
        /// Initializes a new instance of the <b>JavaScriptAttribute</b> class.
        /// </summary>
        /// <param name="variableName"></param>
        /// <param name="variableType"></param>
        public JavaScriptAttribute(string variableName, Type variableType)
        {
            this.Name = variableName;
            this.Type = variableType;
        }
        #endregion

        #region public JavaScriptAttribute(string variableName)
        /// <summary>
        /// Initializes a new instance of the <b>JavaScriptAttribute</b> class.
        /// </summary>
        /// <param name="variableName"></param>
        public JavaScriptAttribute(string variableName)
            : this(variableName, null)
        {
        }
        #endregion
    }
}
